package com.wind.plugin.openAction.Listener;

import com.wind.plugin.openAction.CustomTextEditorAi;

import javax.swing.*;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;

public class MyTableModelListener implements TableModelListener {

    private CustomTextEditorAi editor;

    public MyTableModelListener(CustomTextEditorAi editor) {
        this.editor = editor;
    }

    @Override
    public void tableChanged(TableModelEvent e) {
        // 检查事件类型是否为更新
        if (e.getType() == TableModelEvent.UPDATE) {
            // 检查事件来源是否为按钮点击
            // 获取更新的列索引
            int column = e.getColumn();
            // 忽略第三列（索引为2）
            if (column != 3) {
                // 刷新原始数据
                editor.refreshOriginalData();
                System.out.println("TableModelListener: tableChanged");
            } else {
                System.out.println("TableModelListener: Ignoring update on column 3");
            }
        }
    }

}